package app

import "kvmc/pkg/kvm"

type StopOption struct {
	ClusterName string
	Name        string
	All         bool
	Force       bool
}

func (m *Manager) Stop(option *StopOption) {
	nodes := m.GetClusterNodes(option.ClusterName)
	kvmNodes := make([]*kvm.Node, 0, len(nodes))
	for _, node := range nodes {
		if option.All || node.Name == option.Name {
			kvmNodes = append(kvmNodes, &kvm.Node{
				Hostname: node.Hostname,
				IP:       node.IP,
			})
		}
	}
	k := kvm.NewKvm(kvmNodes)
	k.Stop(option.Force)
}
